package com.gitee.wsl.model.process.request

import com.gitee.wsl.flowing.pipeline.Pipeline
import com.gitee.wsl.flowing.pipeline.PipelinePhase

/**
 * An [HttpClient]'s pipeline used for executing [ProcessRequest].
 */
class RequestPipeline(
    override val developmentMode: Boolean = true
) : Pipeline<Any, ProcessRequestBuilder>(Before, State, Transform, Render, Send) {
    /**
     * All interceptors accept payload as [subject] and try to convert it to [OutgoingContent].
     * Last phase should proceed with [HttpClientCall].
     */
     companion object Phases {
        /**
         * The earliest phase that happens before any other.
         */
         val Before: PipelinePhase = PipelinePhase("Before")

        /**
         * Use this phase to modify a request with a shared state.
         */
         val State: PipelinePhase = PipelinePhase("State")

        /**
         * Transform a request body to supported render format.
         */
         val Transform: PipelinePhase = PipelinePhase("Transform")

        /**
         * Encode a request body to [OutgoingContent].
         */
         val Render: PipelinePhase = PipelinePhase("Render")

        /**
         * A phase for the [HttpSend] plugin.
         */
         val Send: PipelinePhase = PipelinePhase("Send")
    }
}

